package com.dragon.modules.yuegou.enums.code;

import com.dragon.common.constant.enums.IBusinessCode;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 限时折扣态码
 * 
 * @author 李基方
 *
 */
public enum LimitSalesCode implements IBusinessCode {

	LIMITSALES_NO_START(23001, "商品尚未开放购买，敬请期待"),
	
	LIMITSALES_END(23002, "商品已过期，无法购买"),
	
	LIMITSALES_COMPLETE(23003, "该商品已经被抢完啦"),
	
	LIMITSALES_UNLINE(23004, "该商品已下线"),
	
	LIMITSALES_SPU_TIME_OUT(23005, "申请的结束时间大于商品的过期时间"),
	
	LIMITSALES_BEGIN_TIME_ERROR(23006, "活动开始时间小商品的开始时间"),
	
	LIMITSALES_END_TIME_ERROR(23007, "活动结束时间大于商品的结束时间")
	
	
	
	;
	private final Integer code;

	private final String message;

	private LimitSalesCode(Integer code, String message) {
		this.code = code;
		this.message = message;
	}

	public Integer getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	/**
	 * 把code转化为ResponseCode枚举
	 * 
	 * @param code 代码
	 * @return
	 */
	public static LimitSalesCode from(Integer code) {
		if (code == null) {
			return null;
		}
		return CODE_MAP.get(code);
	}

	/**
	 * Code Map for ResponseCode
	 */
	private static final Map<Integer, LimitSalesCode> CODE_MAP = Stream.of(LimitSalesCode.values())
			.collect(Collectors.toMap(LimitSalesCode::getCode, e -> e));
	
}
